package logic

import (
	"autotestservice/testservices/internal/data"
	"context"
	"gitee.com/jmdvirus/jkgo/jk/jklog"

	"autotestservice/testservices/internal/svc"
	"autotestservice/testservices/internal/types"

	"github.com/tal-tech/go-zero/core/logx"
)

type AutotestEditTestOptionUpdateAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAutotestEditTestOptionUpdateAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) AutotestEditTestOptionUpdateAddLogic {
	return AutotestEditTestOptionUpdateAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AutotestEditTestOptionUpdateAddLogic) AutotestEditTestOptionUpdateAdd(req types.TestOptionUpdate) (*types.TestOptionUpdateResponse, error) {

	jklog.L().Debugln("test option update")
	res := types.TestOptionUpdateResponse{
		Code:    0,
		Message: "success",
	}
	data, err := data.AutoTestOptionUpdate(req)
	if err != nil {
		jklog.L().Errorln("update fail ", err)
		res.Code = 10
		res.Message = "db fail"
		return nil, err
	}

	res.Item = *data

	return &res, nil
}
